package org.cashbook.entities;

import java.io.Serializable;
import java.util.logging.Logger;

import org.cashbook.core.IDFactory;
import org.cashbook.utilities.UtilitiesFactory;

public abstract class AbstractUser implements IUser, Serializable {
	private static final long serialVersionUID = 4456023930906411333L;
	protected String name, surname, email;
	protected int userID;
	
	protected static Logger getLogger() {
		return Logger.getLogger(AbstractUser.class.getName());
	}
	
	public AbstractUser(String name, String surname, String email) {
		this.name    = name;
		this.surname = surname;
		this.email   = email;
		this.userID = IDFactory.getUserID();
		
		UtilitiesFactory.getLogger().fine("User instance created [User ID "+ userID + "]", this);
	}

	@Override
	public String getName() {
		UtilitiesFactory.getLogger().finest("Name returned[User ID "+ userID + "]", this);
		return name;
	}

	@Override
	public void setName(String name) {
		UtilitiesFactory.getLogger().finest("Name set[User ID "+ userID + "]", this);
		this.name = name;
	}

	@Override
	public String getSurname() {
		UtilitiesFactory.getLogger().finest("Surname returned[User ID "+ userID + "]", this);
		return surname;
	}

	@Override
	public void setSurname(String surname) {
		UtilitiesFactory.getLogger().finest("Surname set[User ID "+ userID + "]", this);
		this.surname = surname;
	}

	@Override
	public int getID() {
		UtilitiesFactory.getLogger().finest("ID returned[User ID "+ userID + "]", this);
		return userID;
	}

	@Override
	public void setEmail(String email) {
		UtilitiesFactory.getLogger().finest("Email set[User ID "+ userID + "]", this);
		this.email = email;
	}

	@Override
	public String getEmail() {
		UtilitiesFactory.getLogger().finest("Email returned[User ID "+ userID + "]", this);
		return email;
	}
}
